package cn.demo.um.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cn.demo.common.core.domain.BaseEntity;
import org.apache.commons.math3.analysis.ParametricUnivariateFunction;

/**
 * 用户属性配置对象 um_attr_conf
 *
 * @author xtjun
 * @date 2024-07-01
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "um_attr_conf",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class UmAttrConf extends BaseEntity {
    private static final long serialVersionUID = 1L;
    public static final String CONDITION_TYPE = "condition";
    public static final String CONDITION_PREFIX = "condition-";
    @Id
    @Schema(description = "id")
    private String id;

    @Excel(name = "配置类型", dictType = "um_attr_type")
    @Schema(description = "配置类型(字典:um_attr_type)")
    private String attrType;

    @Excel(name = "显示类型", dictType = "um_attr_view_type")
    @Schema(description = "显示类型(字典:um_attr_view_type)")
    private String viewType;

    @Excel(name = "属性代码")
    @Schema(description = "属性代码")
    private String attrCode;

    @Excel(name = "属性名称")
    @Schema(description = "属性名称")
    private String attrName;

    @Excel(name = "字典类型")
    @Schema(description = "字典类型")
    private String dictType;

    @Excel(name = "排序")
    @Schema(description = "排序")
    private Long sort;

    @Excel(name = "是否择偶标准", dictType = "sys_yes_no")
    @Schema(description = "是否择偶标准(字典:sys_yes_no)")
    private Integer isStandard;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = new SqlOperators() {{
        set(UmAttrConf::getAttrType, SqlOperator.EQUALS);
        set(UmAttrConf::getViewType, SqlOperator.EQUALS);
        set(UmAttrConf::getAttrCode, SqlOperator.EQUALS);
        set(UmAttrConf::getAttrName, SqlOperator.LIKE);
        set(UmAttrConf::getDictType, SqlOperator.EQUALS);
        set(UmAttrConf::getSort, SqlOperator.EQUALS);
        set(UmAttrConf::getIsStandard, SqlOperator.EQUALS);
    }};
}
